<?php
class Akun_model extends CI_Model {

    function __construct()
    {
        parent::__construct();
    }
	
	function insert_user($nama, $pass,$email)
	{
		$data = array(
			'nama' => $nama, 
			'password'=>md5($pass),
			'email'=>$email,
			'role'=> 1
			);
		$this->db->insert('"user"', $data);
	}
	
	function cek_username($nama)
	{
		$this->db->select('*');
		$this->db->from('"user"');
		$this->db->where('nama', $nama);
		$result = $this->db->get();
		return $result->row_array();
	}
	
	function get_user_byid($id_user)
	{
		$this->db->select('*');
		$this->db->from('"user"');
		$this->db->where('id_user', $id_user);
		$result = $this->db->get();
		return $result->result_array();
	}
	
	function update_profil1($email, $id)
	{
		$data = array(
			'email' => $email
		);
		$this->db->where('id_user', $id);
		$this->db->update('"user"', $data);
	}
	
	function update_profil2($pass, $email, $id)
	{
		$data = array(
			'password' => md5($pass),
			'email' => $email
		);
		$this->db->where('id_user', $id);
		$this->db->update('"user"', $data);
	}
	
}
?>